package model.uml.state;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import javax.xml.bind.annotation.XmlTransient;

import model.AbstractStatechartComponent;
import model.util.Dimension;
import model.util.Point;

public abstract class AbstractState extends AbstractStatechartComponent
		implements State {

	private Dimension dimension;

	@XmlTransient
	private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
			this);

	public AbstractState(long id, Long parentId, Point location, Dimension dimension) {
		super(id, parentId, location);
		this.dimension = dimension;
	}

	@Override
	public Dimension getDimension() {
		return dimension;
	}

	@Override
	public void setDimension(Dimension dimension) {
		Dimension oldDimension = this.dimension;
		this.dimension = dimension;
		propertyChangeSupport.firePropertyChange(State.Property.DIMENSION.name(),
				oldDimension, dimension);
	}

	public void addPropertyChangeListener(State.Property property,
			PropertyChangeListener listener) {
		this.propertyChangeSupport.addPropertyChangeListener(property.name(),
				listener);
	}

	public void removePropertyChangeListener(State.Property property,
			PropertyChangeListener listener) {
		this.propertyChangeSupport.removePropertyChangeListener(
				property.name(), listener);
	}

}
